#!/bin/bash

add_br()
{
	# Create the bridge interface.
	/sbin/brctl addbr br0

	# Add interfaces to the bridge.
	/sbin/brctl addif br0 eth1

	# Zero IP the interfaces.
	ip addr flush eth1
	ifconfig eth1 0.0.0.0
	#ifconfig tap0 0.0.0.0

	# Put up the bridge.
	ifconfig br0 172.16.1.100 netmask 255.255.255.0 up
	route add default gw 172.16.1.1 metric 1
	# This gives you a fixed IP, just replace the last 2 lines with your normal DHCP command if you want a dynamic IP.
}

del_br()
{
	ifconfig br0 down
	/sbin/brctl delbr br0
	ifconfig eth1 172.16.1.1
}

# clean original setup first
del_br 2>/dev/null

if [[ $# > 0 ]];then
	add_br
fi
